#!/bin/sh

remoteIp=94.191.44.66;
remoteDir=/root/kuan/kuan-nuxt-blog;

# 远程文件夹
clearRemote(){
   echo "[exec]删除远程文件:$remoteIp $remoteDir/.nuxt"
   ssh root@$remoteIp "rm -rf $remoteDir/.nuxt"
}

# 上传文件
uploadDist(){
   echo "[exec]正在上传文件:$remoteIp $remoteDir"

   # 文件列表 .nuxt,static,*.js,*.json,*.lock
   uploadDir='.nuxt static *.js *.json *.lock'
   scp -r $uploadDir root@$remoteIp:$remoteDir
   ssh root@$remoteIp "pm2 restart kuan-nuxt-blog"
}

# 脚本运行起点
echo "[exec]开始自动部署..."
clearRemote
uploadDist;
echo "文件上传结束--"

